package com.tusiyou.homework;

import android.content.Context;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import android.widget.SimpleAdapter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;


public class HotFragment extends Fragment {

    public HotFragment() {
        // Required empty public constructor
    }



    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.fragment_hot, container, false);
    }

    private ListView lv ;
    private List<HashMap<String,Object>> list;
    private String[] data = new String[]{"精选","女神"};
    private String[] data1 = new String[]{"非主流|朴素","帅气|大叔|小鲜肉","御姐|萝莉|萌妹子"};
    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        lv  = (ListView) view.findViewById(R.id.hot_listview);
        list = new ArrayList<>();
        initData();
        SimpleAdapter adapter = new SimpleAdapter(getActivity(),list,R.layout.hot_item,new String[]{"res1","res2"},new int[]{R.id.hot_item_tv1,R.id.hot_item_tv2});

        lv.setAdapter(adapter);
    }

    private void initData() {
        for (int i =0;i<data.length;i++){
            HashMap<String,Object> map = new HashMap<>();
            map.put("res1",data[i]);
            map.put("res2",data1[i]);
            list.add(map);
        }
    }


}
